package com.fun.demo.fun;

public class LockDemo {
    public static void main(String[] args) {
        Object[] locker = new Object[0];
        //线程独占锁
      /*  new Thread(() ->{
            synchronized (locker){
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("1");

            }
        }).start();

        new Thread(() -> {
            synchronized (locker){
                System.out.println("2");
            }
        }).start();*/

      // 可重入锁  同一线程 锁计数器 +1
        synchronized (locker){
            System.out.println(1);
            synchronized (locker){
                System.out.println(2);

                synchronized (locker){
                    System.out.println(3);
                }
            }

        }






    }
}
